package com.hhd.flow.engine.cmd.impl;

import com.hhd.flow.engine.FlowEngine;
import com.hhd.flow.engine.cmd.Command;
import com.hhd.flow.engine.cmd.CommandResult;
import com.hhd.flow.engine.cmd.FlowCommandExecutor;

public class DefaultFlowCommandExecutor implements FlowCommandExecutor {
    private FlowEngine flowEngine;

    @Override
    public <T> CommandResult<T> execute(Command<T> command) {
        command.setEngine(flowEngine);
        command.setCommandExecutor(this);
        return DefaultCommandResult.forResult(command.execute());
    }

    @Override
    public void setFlowEngine(FlowEngine flowEngine) {
        this.flowEngine = flowEngine;
    }
}
